



<ul style='list-style:none;padding-left:0'>
	<volist name='res_Cond' id='vo'>
			<li>
				<div class='line margin-top'>
					<!--一级条件-->
					<div class='x12'>
						<div style='position:relative;float:left'>
							<div style='height:15px;width:15px;border-radius:5px;background:url(__PUBLIC__/Img/ico-set.png);background-size:cover;position:absolute;top:-10px;right:-20px;' class='CondDels CondSet' cid='{$vo.cond_id}' cname='{$vo.cond_name}'  view='{$vo.cond_view}'></div>
							<h3>{$vo.cond_name}</h3>
						</div>
					</div>

					<!--二级条件-->
					<div class='x11 x1-move margin'>
						<volist name='vo.lv2' id='vo2' >
							<div style='float:left;margin:10px;padding:3px 10px;position:relative;'>
								<div style='width:20px;border-radius:5px;height:20px;background:url(__PUBLIC__/Img/ico-close.png);background-size:cover;position:absolute;top:-10px;right:-10px;' class='CondDel'  cid='{$vo2.cond_id}'></div>
								{$vo2.cond_name}
							</div>
						</volist>

						<!--添加-->
						<div style='float:left;margin:10px ' class='CondLv2AddArea hidden'>
							<div class='line'>
								<div class='x7'>
									<input class='input' name='name' style='height:27px' /> 
									<input class='input' type='hidden' name='cid' style='height:27px' value='{$vo.cond_id}' /> 
								</div>
								<div class='x4 x1-move CondLv2AddSub' style='padding-top:2px'>
									<button class='button button-little bg-green ' >添加</button>
								</div>
							</div>
						</div>

						<div style='float:left;padding-top:2px;margin:10px;margin-left:50px;position:relative' class='CondLv2AddBut'>
							<button class='button button-little bg-green' >新增</button>
						</div>
					</div>
				</div>
			</li>
	</volist>
</ul>

<div style='width:100%;height:200px;position:fixed;left:0;top:100px' id='service_cond_list_CondSetArea' class='hidden'>
	<div style='width:50%;height:100%;margin:0 auto;background:green;padding:10px'>
		<h2 style='line-height:50px'>一级条件设置<span id='service_cond_list_CondSetArea_CondName' style='font-size:12px'></span></h2>
		<hr>
		<div style='text-indent:50px;margin-top:20px'><label><input type='checkbox' name='CondSet' />　在发布信息中显示</label></div>
		<div style='display:flex;margin-top:50px'>
			<div style='flex:1;text-align:center'>
				<button id='service_cond_list_CondSetDel' >删除</button>
			</div>
			<div style='flex:2'></div>
			<div style='flex:2;text-align:center'>
				<button id='service_cond_list_CondSetEdit'>提交</button>
				<button id='service_cond_list_CondSetCancel'>取消</button>
			</div>
		</div>
	</div>

</div>

<script>
$(function(){
	$('.CondLv2AddBut').click(function(){
		$(this).addClass('hidden');
		$(this).parent().find('div.CondLv2AddArea').removeClass('hidden');
	});


	//点击设置一级条件
	$('.CondSet').click(function(){
		$('#service_cond_list_CondSetArea').removeClass('hidden');
		sessionStorage.service_cond_list_setCid = $(this).attr('cid');
		sessionStorage.service_cond_list_view = $(this).attr('view');
		var cname = $(this).attr('cname');
		$('#service_cond_list_CondSetArea_CondName').html('　('+cname+')');
		if(sessionStorage.service_cond_list_view == 1){
			$('input[name=CondSet]').attr('checked',true);
		}
	});
	$('#service_cond_list_CondSetEdit').click(function(){
		var cid = sessionStorage.service_cond_list_setCid;
		if($('input[name=CondSet]').get(0).checked){
			var view = 1;
		}else{
			var view = 2;
		}
		$.ajax({
			url:'service_cond_edit',
			data:{
				sid:sessionStorage.ServiceId,
				cid:cid,
				view:view,
				token:'<?php echo Token_Set('CondEdit');?>'
			},
			type:'post',
			success:function(res){
				switch(res){
					case 'e1':
						alert('非法访问！');
					break;
					case 'e2':
						alert('缺少参数！');
					break;
					case 'e3':
						alert('修改失败！');
					break;
					case 'ok':
						alert('修改成功！');
					break;
				}
				location.reload(true);
			}
		});
	});

	$('#service_cond_list_CondSetCancel').click(function(){
		$('#service_cond_list_CondSetArea').addClass('hidden');
	});
	$('#service_cond_list_CondSetDel').click(function(){
		if(!confirm('确认删除?')){
			exit;
		}
		var token = '<?php echo Token_Set('CondLv1Del');?>';
		$.ajax({
			url:'service_cond_del',
			type:'post',
			data:{
				sid:sessionStorage.ServiceId,
				cid:sessionStorage.service_cond_list_setCid,
				token:token
			},
			success:function(res){
				switch(res){
					case 'e1':
						alert('缺少参数!');
						break;
					case 'e2':
						alert('非法访问！');
						break;
					case 'e3':
						alert('删除失败!');
						break;
					case 'ok':
						alert('删除成功！');
						break;
				}
				location.reload(true);
			}
		});	
	});


	//条件删除
	$('.CondDel').click(function(){
		if(!confirm('确认删除?')){
			exit;
		}
		var cid = $(this).attr('cid');
		var token = '<?php echo Token_Set('CondLv1Del');?>';
		$.ajax({
			url:'service_cond_del',
			type:'post',
			data:{
				sid:sessionStorage.ServiceId,
				cid:cid,
				token:token
			},
			success:function(res){
				switch(res){
					case 'e1':
						alert('缺少参数!');
						break;
					case 'e2':
						alert('非法访问！');
						break;
					case 'e3':
						alert('删除失败!');
						break;
					case 'ok':
						alert('删除成功！');
						break;
				}
				location.reload(true);
			}
		});
	});

	//二级条件添加 
	$('.CondLv2AddSub').click(function(){
		var sid = sessionStorage.ServiceId;
		var name = $(this).parent().find('input[name=name]').val().trim();
		var cid = $(this).parent().find('input[name=cid]').val().trim();
		var token = '<?php echo Token_Set('CondLv2Add');?>';
		if(!sid || !name || !cid){
			alert('缺少参数！');exit;
		}
		$.ajax({
			url:'service_cond_lv2_sub',
			type:'post',
			data:{
				sid:sid,
				cid:cid,
				name:name,
				token:token
			},
			success:function(res){
				switch(res){
					case 'e1':
						alert('缺少参数!');
						break;
					case 'e2':
						alert('非法访问！');
						break;
					case 'e3':
						alert('添加失败!');
						break;
					case 'ok':
						alert('添加成功！');
						break;
				}
				location.reload(true);
			}
		});
	});



});
</script>